package com.example.practice2023.controller;

import com.example.practice2023.pojo.Carousel;
import com.example.practice2023.service.CarouselService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * ClassName: CarouselController
 * Package: com.example.practice2023.controller
 * Description:
 *
 * @Author hyx
 * @Create 2023/7/3 20:29
 * @Version 1.0
 */
@RestController
@RequestMapping("/carousel")
public class CarouselController {
    @Resource
    private CarouselService carouselService;

    @RequestMapping(value = "/selectByPage", method = RequestMethod.GET)
    public Map<String, Object> selectByPage(int page, int limit, Carousel carousel) {
        return carouselService.selectByPage(page, limit, carousel);
    }

    @RequestMapping(value = "/select", method = RequestMethod.GET)
    public Map<String, Object> select() {
        return carouselService.select();
    }

    @RequestMapping(value = "/insert", method = RequestMethod.POST)
    public Map<String, Object> insert(@RequestBody Carousel carousel) {
        return carouselService.insert(carousel);
    }

    @RequestMapping(value = "/updateById", method = RequestMethod.POST)
    public Map<String, Object> updateById(@RequestBody Carousel carousel) {
        return carouselService.updateById(carousel);
    }

    @RequestMapping(value = "/status", method = RequestMethod.POST)
    public Map<String, Object> updateStatus(@RequestBody Carousel carousel) {
        return carouselService.updateByStatus(carousel);
    }

    @RequestMapping(value = "/deleteById", method = RequestMethod.POST)
    public Map<String, Object> deleteById(@RequestParam Integer id) {
        return carouselService.deleteById(id);
    }

}
